import React, { FC, useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { Typography, Space } from "antd";
import { StarTwoTone } from "@ant-design/icons";
import styles from "./Logo.module.scss";
import { HOME_PATH, MANAGE_PATH_LIST } from "../router";
// redux
import useGetUserInfo from "../hooks/useGetUserInfo";

const { Title } = Typography;
const Logo: FC = () => {
  const { username } = useGetUserInfo();
  const [pathName, setPathName] = useState(HOME_PATH);
  useEffect(() => {
    if (username) {
      setPathName(MANAGE_PATH_LIST);
    }
  }, [pathName]);

  return (
    <div className={styles.logo}>
      <Link to={pathName}>
        <Space>
          <Title>
            <StarTwoTone />
          </Title>
          <Title>问卷星项目</Title>
        </Space>
      </Link>
    </div>
  );
};

export default Logo;
